package com.flyxiaozhu.erp.core.repositories;

import com.flyxiaozhu.erp.core.entities.GoodsTag;
import com.flyxiaozhu.erp.core.pojos.GoodsTagsPojo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.Collection;
import java.util.List;

/**
 * @author flyxiaozhu
 * @date 2019-04-12 18:37
 */
public interface GoodsTagRepository extends JpaRepository<GoodsTag, Long>, JpaSpecificationExecutor<GoodsTag> {
    GoodsTag findByTitle(String title);

    List<GoodsTag> findByIdIn(Collection ids);

    @Query(nativeQuery = true)
    List<GoodsTagsPojo> getTagedGoodsByTagsIdIn(Collection<Long> ids);

    @Query(nativeQuery = true)
    List<GoodsTagsPojo> getTagedGoodsByGoodsIdIn(Collection<Long> ids);

    @Query(nativeQuery = true)
    List<GoodsTagsPojo> getTagedGoodsByTagsId(Long id);
}
